import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2024-12-18
 * Time: 12:50
 */
public class test1 {
    /*
    NewCoder BM48  数据流中的中位数

     */

    private ArrayList<Integer> val = new ArrayList<>();
    public void Insert(Integer num) {
        if(val.isEmpty()){
            val.add(num);
        }else{
            int i=0;
            for(;i<val.size();i++){
                if(num<=val.get(i)){
                    break;
                }
            }
            val.add(i,num);
        }
    }

    public Double GetMedian() {
        int n = val.size();
        if(n%2==1){
            return (double) val.get(n/2);
        }else{
            double a = val.get(n/2);
            double b = val.get(n/2-1);
            return (a+b)/2;
        }
    }
}
